#!/bin/bash

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

if [ $# -ne 1 ]
then
    echo "Usage: `basename $0` storageType"
    echo "where storageType is an integer from:"
    echo "1=COO, 2=CSR, 3=DIA, 4=ELL, 5=HYB"
    echo "and all other numbers use default COO"
    exit 65
fi

cd cufflink

for i in cufflink_CG cufflink_DiagPCG cufflink_SmAPCG cufflink_CG_Parallel cufflink_DiagPCG_Parallel cufflink_SmAPCG_Parallel
do
	cd $i

	for j in N10 N50 N100 N500 N1000 N2000
	do
            sed -i "s/storage.*/storage\t\t$1;\/\/COO=1 CSR=2 DIA=3 ELL=4 HYB=5 all other numbers use default COO/g" $j/system/fvSolution
	done

	cd ..
done

cd ..

#this isn't necessary for the openfoam solvers since Openfoam does not have any other sotrage format except the lduMatrix format which is only in OpenFOAM.
#cd ../OpenFOAM
#
#for i in CG DPCG GAMG DPCG-parallel4 DPCG-parallel6 GAMG6
#do
#	cd $i
#
#	for j in N10 N50 N100 N500 N1000 N2000
#	do
#            sed -i "s/storage.*/storage\t\t$1;\/\/COO=1 CSR=2 DIA=3 ELL=4 HYB=5 all other numbers use default COO/g" $j/system/fvSolution
#        done
#	
#	cd ..
#done
#
#cd ..

